//
//  LoginVC.swift
//  LoginDemo
//
//  Created by cailei on 2022/7/12.
//

import UIKit

class LoginVC: UIViewController {

    @IBOutlet weak var errorLabel: UILabel!
    
    @IBOutlet weak var usernameTextfield: UITextField!
    
    @IBOutlet weak var passwordTextfield: UITextField!

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == "success" {
            if let des = segue.destination as? SuccessVC {
                des.text = "登录成功！"
            }
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }


    override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
        if identifier == "register" {
            return true
        }
        if usernameTextfield.text ?? "" == "" {
            errorLabel.text = "用户名不能为空"
            return false
        }
        if passwordTextfield.text ?? "" == "" {
            errorLabel.text = "密码不能为空"
            return false
        }
        return true
    }
}

